﻿using DotNet.JCore.Service;
using DotNet.Web.Areas.AuthWeb.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DotNet.JCore.Entity;
using DotNet.Extensions;

namespace DotNet.Web.Areas.Mobile.Controllers
{
    public class M_InspectionlogController : AuthController
    {
        private InspectorRegistrationSumService Service = new InspectorRegistrationSumService();
        private EmployeeService EmployeeService = new EmployeeService();
        //public ActionResult Index()
        //{
        //    return View();
        //}
        public ActionResult Index(string InspectorsName)
        {
            string checkinTime = System.DateTime.Now.ToShortDateString();
            // var entity = Service.Get(InspectorsName, checkinTime);
            //if (entity == null) return NotFound(InspectorsName, checkinTime);
            //return View(entity);

            //先统计一下当日数据，将当日数据插入表中，再执行查询
            Service.Proc_InspectorRegistrationSum("Proc_InspectorRegistrationSum");
            var entity = EmployeeService.GetByUserInspectorsName(InspectorsName);
            if (entity!=null)
            {
                ViewBag.PointName = entity.PointName;
            }
            var list = Service.M_GetPageList(PageInfo(),InspectorsName, checkinTime.ToDateTimeOrNull());
            ViewBag.checkinTime = System.DateTime.Now.ToShortDateString();
            ViewBag.Count = list.Count.ToString();
            ViewBag.InspectorsName = InspectorsName;
            ViewBag.ToDateTime = System.DateTime.Now.ToShortDateString();
            return View(list);
        }
    }
}